package cn.zh.npro.Activity;

import android.os.CountDownTimer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import cn.zh.npro.R;

public class BindActivity extends BaseActivity {

    Mycount mycount;
    Button reout_time;
    ImageView mc_back;
    TextView cpscom;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bind);
        initbd();
       }


      public void initbd(){
          reout_time= (Button) findViewById(R.id.reout_time);
          mc_back=findViewById(R.id.mc_back);
          cpscom=findViewById(R.id.cpscom);
          mycount = new Mycount(60*1000,1000);
          reout_time.setOnClickListener(this);
          mc_back.setOnClickListener(this);
          cpscom.setOnClickListener(this);
         }


    @Override
    public void onClick(View view) {
        super.onClick(view);
        int id=view.getId();
        switch (id){
            case R.id.reout_time:
                mycount.start();
                reout_time.setEnabled(false);
                break;
            case R.id.mc_back:
                finish();
                break;
            case R.id.cpscom:
                finish();
                break;

         }

      }

    public class Mycount extends CountDownTimer {
        public Mycount(long millisInFuture, long countDownInterval) {
            super(millisInFuture, countDownInterval);
        }
        @Override
        public void onTick(long millisUntilFinished) {
            long myhour = (millisUntilFinished / 1000) / 3600;
            long myminute = ((millisUntilFinished / 1000) - myhour * 3600) / 60;
            long mysecond = millisUntilFinished / 1000 - myhour * 3600
                    - myminute * 60;
            reout_time.setText(mysecond+"后重发");
        }

        @Override
        public void onFinish() {
            reout_time.setText("重新发送");
            reout_time.setEnabled(true);
        }
    }



}
